package com.th.supcom.pds.deptdispensary.client.widget;

import net.carefx.framework.container.client.constant.FrameworkConstants;
import net.carefx.framework.container.client.context.AppContext;

import com.extjs.gxt.ui.client.store.Store;
import com.extjs.gxt.ui.client.widget.form.ComboBox;
import com.extjs.gxt.ui.client.widget.form.ComboBox.TriggerAction;
import com.extjs.gxt.ui.client.widget.form.SimpleComboBox;
import com.extjs.gxt.ui.client.widget.form.StoreFilterField;
import com.th.supcom.framework.dict.web.gwt.client.DictComboBox;
import com.th.supcom.framework.dict.web.gwt.client.model.DictModel;
import com.th.supcom.framework.organization.web.gwt.client.OrgComboBox;
import com.th.supcom.framework.organization.web.gwt.client.model.OrganizationModel;
import com.th.supcom.pds.common.client.model.CodeConstants;
import com.th.supcom.pds.common.utils.ClientUtils;
import com.th.supcom.pds.config.client.common.PdsConfigConstant;
import com.th.supcom.pds.deptdispensary.client.model.DeptVsDispensaryModel;

/**
 * 护理单元药房配置Fields
 * 
 * @author 杨冲
 */
public class DeptVsDispensaryFields
{
    private DictComboBox m_phamDispenseTypeBox;
    private DictComboBox m_phamMaterialBox;
    private DictComboBox m_isReturnBox;
    private DictComboBox m_isArrearBox;
    private OrgComboBox m_deptBox;
    private DictComboBox m_shiftBox;
    private OrgComboBox m_dispensaryBox;
    private DictComboBox m_withdrawTypeBox;
    private SimpleComboBox <Integer> m_priorityBox;
    private StoreFilterField <DeptVsDispensaryModel> m_filter;

    /**
     * 构造函数
     */
    public DeptVsDispensaryFields ()
    {
        createFields ();
    }

    /**
     * 创建组件
     */
    private void createFields ()
    {
        m_phamDispenseTypeBox = new DictComboBox (PdsConfigConstant.DISPENSE_TYPE_DICT_CODE);
        m_phamDispenseTypeBox.setFieldLabel (FrameworkConstants.FORM_MUST_FILL_TIP + "摆药类型");
        m_phamDispenseTypeBox.setAllowBlank (false);

        m_phamMaterialBox = new DictComboBox (CodeConstants.DMS_DRUG_MATERIAL_CLASSIFY_CODE);
        m_phamMaterialBox.setFieldLabel (FrameworkConstants.FORM_MUST_FILL_TIP + "药品材质");
        m_phamMaterialBox.setAllowBlank (false);

        m_isReturnBox = new DictComboBox (PdsConfigConstant.IS_RETURN);
        m_isReturnBox.setFieldLabel (FrameworkConstants.FORM_MUST_FILL_TIP + "强行可退");
        m_isReturnBox.setAllowBlank (false);

        m_isArrearBox = new DictComboBox (PdsConfigConstant.IS_ARREAR);
        m_isArrearBox.setFieldLabel (FrameworkConstants.FORM_MUST_FILL_TIP + "欠费摆药");
        m_isArrearBox.setAllowBlank (false);

        m_deptBox = new OrgComboBox ();
        m_deptBox.setFieldLabel (FrameworkConstants.FORM_MUST_FILL_TIP + "科&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp室");
        OrganizationModel model = new OrganizationModel ();
        model.setCode (ClientUtils.getOrgModel ().getOrgCode ());
        model.setName (ClientUtils.getOrgModel ().getOrgName ());
        m_deptBox.setValue (model);
        m_deptBox.setAllowBlank (false);

        m_shiftBox = new DictComboBox (PdsConfigConstant.SHIFT_TYPE_DICT_CODE);
        m_shiftBox.setFieldLabel (FrameworkConstants.FORM_MUST_FILL_TIP + "班&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp次");
        m_shiftBox.setAllowBlank (false);

        m_dispensaryBox = new OrgComboBox ();
        m_dispensaryBox.setFieldLabel (FrameworkConstants.FORM_MUST_FILL_TIP
                                       + "药&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;房");
        m_dispensaryBox.setAllowBlank (false);

        m_priorityBox = new SimpleComboBox <Integer> ();
        m_priorityBox.setFieldLabel (FrameworkConstants.FORM_MUST_FILL_TIP + "优&nbsp;&nbsp;先&nbsp;&nbsp;级");
        m_priorityBox.setAllowBlank (false);
        m_priorityBox.setTriggerAction (TriggerAction.ALL);

        m_withdrawTypeBox = new DictComboBox (PdsConfigConstant.WITHDRAW_YTPE_DICT_CODE);
        m_withdrawTypeBox.setFieldLabel (FrameworkConstants.FORM_MUST_FILL_TIP + "退药方式");
        m_withdrawTypeBox.setAllowBlank (false);
        m_withdrawTypeBox.setTriggerAction (TriggerAction.ALL);

        m_filter = new StoreFilterField <DeptVsDispensaryModel> ()
        {

            @Override
            protected boolean doSelect (Store <DeptVsDispensaryModel> store, DeptVsDispensaryModel parent,
                                        DeptVsDispensaryModel record, String property, String filter)
            {
                if (record.getDeptName () != null && record.getDeptName ().contains (filter))
                {
                    return true;
                }

                if (record.getDispensaryName () != null && record.getDispensaryName ().contains (filter))
                {
                    return true;
                }

                return false;
            }
        };
        m_filter.setWidth (350);
        m_filter.setEmptyText ("请输入药房名称、护理单元名称过滤");
    }

    /**
     * 获取药品类型ComboBox
     * 
     * @return
     */
    public ComboBox <DictModel> getPhamDispenseTypeBox ()
    {

        return m_phamDispenseTypeBox;
    }

    /**
     * 获取是否欠费摆药ComboBox
     * 
     * @return
     */
    public DictComboBox getIsArrearBox ()
    {
        return m_isArrearBox;
    }

    /**
     * 获取护理单元ComboBox
     * 
     * @return
     */
    public ComboBox <OrganizationModel> getDeptBox ()
    {

        return m_deptBox;
    }

    /**
     * 获取班次ComboBox
     * 
     * @return
     */
    public ComboBox <DictModel> getShiftBox ()
    {

        return m_shiftBox;
    }

    /**
     * 获取药房ComboBox
     * 
     * @return
     */
    public ComboBox <OrganizationModel> getDispensaryBox ()
    {

        return m_dispensaryBox;
    }

    /**
     * 获取优先级ComboBox
     * 
     * @return
     */
    public SimpleComboBox <Integer> getPriorityBox ()
    {

        return m_priorityBox;
    }

    /**
     * 获取过滤组件
     * 
     * @return
     */
    public StoreFilterField <DeptVsDispensaryModel> getFilter ()
    {

        return m_filter;
    }

    /**
     * 获取药品材质组件
     * 
     * @return
     */
    public DictComboBox getPhamMaterialBox ()
    {

        return m_phamMaterialBox;
    }

    /**
     * 获取 退药方式组件
     * 
     * @return
     */
    public DictComboBox getWithdrawTypeBox ()
    {
        return m_withdrawTypeBox;
    }

    /**
     * 获取 不可退药品是否强行可退
     * 
     * @return
     */
    public DictComboBox getIsReturnBox ()
    {
        return m_isReturnBox;
    }

}
